/*
 * action.h
 */

#ifndef ACTION_H_
#define ACTION_H_

#include "event.h"
#include "listener.h"

/*
 * The action struct.
 */
typedef struct {
    event_t type;
    void *info;
} action;

/*
 * Creates a new action with the given corresponding event, listener, and
 * function that does the given action.
 */
action* create_action( event_t type, void *info );

/*
 * Calls the event handler registered for the given action's event_t, frees the
 * given action, and informs all listeners registered to that event_t.
 * NOTE: a->info is freed in the process of freeing the action after the event
 * is generated.
 */
void handle_action( action *a );

event * event_generate( action *a );

event_t event_register( event * (*event_handler)(action*) );

#endif
